using UnityEngine;

namespace PKGames.Analytics
{
	[SerializeField]
	public class UnityEncodedPrimitiveData
	{
		private enum PrimitiveType
		{
			String,
			Bool,
			Int,
			Float,
			Unknown
		}

		[SerializeField]
		private string type;

		[SerializeField]
		private string data;

		public string Data => data;

		public UnityEncodedPrimitiveData(int data)
		{
			type = PrimitiveType.Int.ToString();
			this.data = data.ToString();
		}

		public UnityEncodedPrimitiveData(float data)
		{
			type = PrimitiveType.Float.ToString();
			this.data = FloatToAnalyticsParameter(data);
		}

		public UnityEncodedPrimitiveData(bool data)
		{
			type = PrimitiveType.Bool.ToString();
			this.data = data.ToString();
		}

		public UnityEncodedPrimitiveData(string data)
		{
			type = PrimitiveType.String.ToString();
			this.data = data;
		}

		private static string FloatToAnalyticsParameter(float parameter)
		{
			return parameter.ToString("0.00000");
		}
	}
}
